package event;

import observer.ObservedList;
import observer.Copiable;

/**
 * This is for events in which an element is removed from an {@link ObservedList}.
 *
 * @author Neil Dickson
 */
public class ListRemoveEvent<E extends Copiable> implements Undoable {
	private	ObservedList<E>	list;
	private	E				element;
	private	int				index;

	public ListRemoveEvent(ObservedList<E> list,E element,int index) {
		this.list = list;
		this.element = element;
		this.index = index;
	}

	public Undoable undo() {
		list.add(index,element);
		// FIXME: Move the view to the location of the changed ObservedList.
		return new ListAddEvent<E>(list,index);
	}

	public String getDescription() {
		return "Removing "+element;
	}
}
